<template>
	<view class="content">
		<u-navbar safeAreaInsetTop placeholder fixed autoBack>
			<view class="u-nav-slot color_ling text_weight" slot="center">
				天商订单
			</view>
			<view class="u-nav-slot text_a color_san" slot="right">
				<text @click="refund">退货管理</text>
			</view>
		</u-navbar>
		<u-sticky bgColor="#fff">
			<u-tabs :list="list1" lineColor="rgba(243, 39, 28, 1)" :current="currenttabtow" @click="clicktabtow"
				:activeStyle="{
		   	    color: '#000000',
		   	    fontWeight: 'bold',
		   	    transform: 'scale(1.05)'
		   	}" :inactiveStyle="{
		   	            color: 'rgba(102, 102, 102, 1)',
		   				fontWeight: 'bold',
		   	            transform: 'scale(1)'
		   	        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;"></u-tabs>
		</u-sticky>
		<view class="padding_lrb">
			<view class="ffffff padding border_2 margin_top" v-for="(item,index) in list.data" :key="item.id"
				@click="goOrderInfo(item.id)">
				<view class="flexbetween">
					<view class="color_ling text_z margin_right1">{{item.order_no}}</view>
					<!-- 普通订单 -->
					<view class="hongsetext" style="color: rgba(255, 0, 0, 1);" v-if="item.state==-1">已取消</view>
					<view class="hongsetext" style="color: rgba(255, 0, 0, 1);" v-if="item.state==1">待支付</view>
					<view class="hongsetext" style="color: #ffa126;" v-if="item.state==2">待成团</view>
					<view class="huangsetext" style="color:rgba(212, 139, 57, 1);" v-if="item.state==3">待发货</view>
					<view class="huangsetext" style="color:rgba(212, 139, 57, 1);" v-if="item.state==4">待收货</view>
					<view class="huangsetext" style="color:rgba(212, 139, 57, 1);" v-if="item.state==5">待评论</view>
					<view class="huangsetext" style="color:rgba(19, 196, 99, 1);" v-if="item.state==6">已完成</view>
					<view class="hongsetext" style="color:rgba(19, 196, 99, 1);" v-if="item.state==7">已归档</view>
					<view class="hongsetext" style="color:rgba(19, 196, 99, 1);" v-if="item.state==8">已退款</view>
				</view>
				<view class="flexbetween xiahuax margin_top" v-for="(ite,index1) in item.ordergoods" :key="ite.id">
					<view class="shilitu">
						<image :src="ite.goods_image_text" mode=""></image>
					</view>
					<view class="" style="width: 74%;">
						<view class="yihang text_zi">{{ite.goods_name}}</view>
						<view class="baise">{{ite.sku}}</view>
						<view class="flexbetween">
							<view class="qianshu">¥{{ite.pay_price}}</view>
							<view class="shuliang">X{{ite.goods_num}}</view>
						</view>
					</view>
				</view>
				<view class="flexright margin_top">
					<view class="nostrongtext margin_right1">共计<text class="ershisi">{{item.total_num}}</text>件商品</view>
					<view class="nostrongtext">合计
						<text class="ershisi">￥{{item.total_price}}</text>
					</view>
				</view>
				<!-- 所有按钮 -->
				<view class="flexright margin_top">
					<view class="huangsebtn" @click.stop="goSendGoods(item.id)" v-show="item.can_deliver">立即发货</view>
					<view class="huangsebtn margin_left3" @click.stop="goLogisticsInfo(item.id)"
						v-show="item.can_express">查看物流</view>
					<!-- <view class="huisebtn margin_left3">删除订单</view> -->
					<view class="huangsebtn margin_left3" @click.stop="estimate(item.id)" v-show="item.can_commentlist">
						查看评价</view>
				</view>
			</view>
			<view class="flexcenter placeholderBoxTop" v-if="!list.data.length">
				<image class="placeholderBox" src="/static/placeholderimg.png" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				columns: [],
				currenttabtow: 0, //0=全部,1=待付款,2=待成团,3=待发货,4=待收货,5=待评价,6=已完成
				list1: [{
						name: '全部',
					},
					{
						name: '待付款',
					},
					{
						name: '待分享',
					},
					{
						name: '待发货',
					},
					{
						name: '待收货',
					},
					{
						name: '已完成',
					}
				],
				page: 1,
				list: {
					data: []
				},
				orderDetail: {}, // 订单详情内容
			}
		},
		onLoad(options) {
			this.currenttabtow = options.value
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request("/api/shop.goods_order/orderlist", 'GET', {
					page: page || 1,
					state: _this.currenttabtow == 5 ? 6 : _this.currenttabtow
				}, false, false, true).then(res => { //我的订单接口
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page)
			},
			estimate(id) { //查看评价
				uni.navigateTo({
					url: "/pages_mine/allEval?type=1&id=" + id
				})
			},
			goLogisticsInfo(id) { //查看物流+商家端+商品订单
				uni.navigateTo({
					url: "/pages_mine/logisticsInfo?type=1&id=" + id
				})
			},
			goSendGoods(id) { //立即发货
				uni.navigateTo({
					url: "/pages_mine/onceSendGoods?id=" + id
				})
			},
			goOrderInfo(id) { //订单详情
				uni.navigateTo({
					url: "/pages_mine/businessOrderInfo?id=" + id
				})
			},
			clicktabtow(e) {
				this.currenttabtow = e.index;
				this.init()
			},
			refund() {
				uni.navigateTo({
					url: "/pages_mine/refundOrder"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	// ::v-deep.u-tabs__wrapper__nav__item {
	// 	//平均分配
	// 	flex: 1;
	// }
	.imgShop {
		width: 26.62rpx;
		height: 24rpx;

	}

	.fuzhi {
		margin: 0rpx 30rpx 30rpx 30rpx;
	}

	.dan {
		width: 80vw;
		padding: 64rpx 40rpx 0rpx 40rpx;
	}

	.wuliu {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.zhongtong {

		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		padding: 34rpx 82rpx;
		border: 1rpx solid rgba(223, 223, 223, 1);
		border-radius: 10rpx;
		margin: 87rpx 0rpx 0rpx 0rpx;
	}

	.copy {
		padding: 25rpx 150rpx;
		border-radius: 51rpx;
		background-color: RGBA(225, 159, 83, 1);
		margin-top: 109rpx;
		color: #fff;
	}

	.text_zi {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.number {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.nostrongtext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.baise {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
		margin: 12rpx 0rpx;
	}

	.huangsebtn {
		border: 2rpx solid rgba(243, 39, 28, 1);
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: rgba(243, 39, 28, 1);
	}

	.huisebtn {
		border: 2rpx solid #666666;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.ershisi {
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 800;
		color: rgba(243, 39, 28, 1);
	}

	.xiahuax {
		padding-bottom: 30rpx;
		border-bottom: 1rpx solid rgba(153, 153, 153, .1);
	}

	.shuliang {
		font-size: 26rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: rgba(243, 39, 28, 1);
	}

	.qianshu {
		font-size: 30rpx;
		font-family: DIN Next LT Pro-Bold, DIN Next LT Pro;
		font-weight: bold;
		color: rgba(243, 39, 28, 1);
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.shilitu {
		width: 134rpx;
		height: 128rpx;
		border-radius: 14rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.lvsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #00C058;
	}

	.huangsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: RGBA(255, 117, 16, 1);
	}

	.hongsetext {
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: RGBA(255, 117, 16, 1);
	}

	.marginleft3 {
		margin-left: 30rpx;
	}
</style>